/*
 * FlightController.h
 *
 *  Created on: Jan 14, 2014
 *      Author: ppks
 */

#ifndef FLIGHTCONTROLLER_H_
#define FLIGHTCONTROLLER_H_

#include "types.h"

/********************************************************************************/
/* Constants Definition                                                         */
/********************************************************************************/
#define RC_CHECK_TIME_PERIOD_IN_MICROS      20000

/********************************************************************************/
/* Global Variables Declaration                                                 */
/********************************************************************************/
extern uint32_t currentLoopTimeStamp;
extern uint16_t previousLoopTimeStamp;
extern uint16_t loopCycleTime;

extern imu_t imuData;
extern alt_t baroData;
extern analog_t analogData;
extern alt_t alt;
extern att_t att;

extern cal_t calibration;
extern calibration_data_t calData;

extern flags_struct_t globalFlags;

extern int16_t rcData[];
extern int16_t rcCommand[];
extern int16_t motorControlData[];
extern int16_t servoControlData[];
extern int16_t axisPID[3];

extern uint8_t dynP8[2];
extern uint8_t dynD8[2];

extern int32_t AltHold;
extern int16_t magHold;
extern int16_t headFreeModeHold;
extern int16_t BaroPID;
extern int16_t errorAltitudeI;
extern int16_t initialThrottleHold;

#if defined(THROTTLE_ANGLE_CORRECTION)
extern int16_t throttleAngleCorrection;
extern int8_t  cosZ;
#endif /* defined(THROTTLE_ANGLE_CORRECTION) */

/********************************************************************************/
/* Exported Functions Prototypes                                                */
/********************************************************************************/
void FlightController_Init(void);
void FlightController_Main(void);
void FlightController_Process(uint32_t currentTimeStamp);
void FlightController_SystemArm(void);
void FlightController_SystemDisarm(void);
#endif /* FLIGHTCONTROLLER_H_ */
